//
//  AZUserModelTrue.swift
//  sinaWB
//
//  Created by AzeryKiss on 16/2/28.
//  Copyright © 2016年 AzeryKiss. All rights reserved.
//

import UIKit

class AZUserModelTrue: NSObject , NSCoding{

    ///profile_image_url	string	用户头像地址（中图），50×50像素
    var profile_image_url: String?
    ///screen_name	string	用户昵称
    var screen_name: String?

    func  encodeWithCoder(aCoder : NSCoder) {
        aCoder.encodeObject(screen_name, forKey: "screen_name")
        aCoder.encodeObject(profile_image_url, forKey: "profile_image_url")
    }
    
    required init?(coder  aDecoder:NSCoder) {
        self.screen_name = aDecoder.decodeObjectForKey("screen_name") as? String
        self.profile_image_url = aDecoder.decodeObjectForKey("profile_image_url") as? String
    }
    

    
    func saveData() {
        
        let path = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true).last
        let filePath = (path! as NSString).stringByAppendingPathComponent("userModel.data")
        
        NSKeyedArchiver.archiveRootObject(self, toFile: filePath)
        
    }
    
    init(dict: [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String){}
    
}
